package com.service;

import com.config.Person;
import com.config.VoiceTemplateConfig;
import com.dtdream.vanyar.message.factory.SenderFactory;
import com.dtdream.vanyar.message.mail.service.MailService;
import com.dtdream.vanyar.message.sms.service.SmsService;
import io.terminus.common.model.Response;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Required;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.core.env.Environment;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * Created by pengfei on 16/7/6.
 */
@EnableConfigurationProperties(Person.class)
@RequestMapping
@RestController
public class ClientService implements InitializingBean {
    @Autowired
    private Environment env;
//    @Value("${dubbo.timeout}")
//    private String name;
//    @Autowired
//    private VoiceTemplateConfig voiceTemplateConfig;
    public void afterPropertiesSet() throws Exception {
        System.out.println(11);
    }
    @Autowired
    private SenderFactory mailFactory;
    @Autowired
    private SenderFactory factory;
    @RequestMapping("/a")
    public String test(){
        MailService mailService = mailFactory.carrier(SenderFactory.SENDER_E.ASYNC);
//
//        Map map = new HashMap();
//
//        List<String> list = new ArrayList<String>();
//        list.add("591288005@qq.com");
//        list.add("zhoupengfeippt@163.com");
//        Response<Boolean> rs = mailService.send("zhuti","tag","content",list);
//        System.out.println(rs);

        SmsService smsService = factory.messenger(SenderFactory.SENDER_E.ASYNC);
        Map map = new HashMap();
        map.put("region","美99国");

        List<String> list = new ArrayList<String>();
        list.add("18757156909");
        list.add("15651658592");
        Response<Boolean> rs = smsService.sendGroup("expert_invite",map,list);
        System.out.println(rs);

        return "xxxxx";
    }
}
